/*
 * JarFile.h
 *
 *  Created on: 2011-7-9
 *      Author: gexiao
 */

/*
 * Decode jar/apk/zip files.
 */
#ifndef JARFILE_H_
#define JARFILE_H_
#include "DvmDex.h"
#include "../libdex/ZipArchive.h"

#include <stdbool.h>
/*
 * This represents an open, scanned Jar file. (It's actually for any Zip
 * archive that happens to hold a Dex file.)
 */
typedef struct JarFile {
	ZipArchive archive;
	char* cacheFileName;
	DvmDex* pDvmDex;
} JarFile;

/*
 * Open the Zip archive and get a list of the classfile entries.
 *
 * On success, returns 0 and sets "*ppJarFile" to a newly-allocated JarFile.
 * On failure, returns  a meaningful error code [currently just -1]
 */
int dvmJarFileOpen(const char* fileName, JarFile** ppJarFile, bool isBootstrap);

// pry the DexFile out of a JarFile
INLINE DvmDex* dvmGetJarFileDex(JarFile* pJarFile) {
	return pJarFile->pDvmDex;
}

//get full path of optimized DEX file
INLINE const char* dvmGetJarFileCacheFileName(JarFile* pJarFile) {
    return pJarFile->cacheFileName;
}
#endif /* JARFILE_H_ */
